6beab551a2907ee401f557a1af2ace927c267015,opennms-services/src/main/java/org/opennms/netmgt/eventd/EventConfigurationManager.java,EventConfigurationManager,loadConfiguration,#Reader#,170
Before Change
Category log = ThreadCategory.getInstance();
synchronized (m_eventConf) {
Events toplevel = null;
toplevel = (Events) Unmarshaller.unmarshal(Events.class, rdr);
m_eventConf.clear();
Enumeration e = toplevel.enumerateEvent();
while (e.hasMoreElements()) {
Event event = (Event) e.nextElement();
m_eventConf.put(event);
}
m_secureTags = toplevel.getGlobal().getSecurity().getDoNotOverride();
Enumeration e2 = toplevel.enumerateEventFile();
while (e2.hasMoreElements()) {
String eventfile = (String) e2.nextElement();
InputStream fileIn = new FileInputStream(eventfile);
if (fileIn == null) {
throw new IOException("Eventconf: Failed to load/locate events file: " + eventfile);
}
if (log.isDebugEnabled()) {
log.debug("Eventconf: Loading event file: " + eventfile);
}
Reader filerdr = new InputStreamReader(fileIn);
Events filelevel = null;
filelevel = (Events) Unmarshaller.unmarshal(Events.class, filerdr);
if (filelevel.getGlobal() != null) {
throw new ValidationException("The event file " + eventfile + " included from the top-level event configuration file cannot have a 'global' element");
}
if (filelevel.getEventFileCollection().size() > 0) {
throw new ValidationException("The event file " + eventfile + " included from the top-level event configuration file cannot include other configuration files: " + StringUtils.collectionToCommaDelimitedString(filelevel.getEventFileCollection()));
}
Enumeration efile = filelevel.enumerateEvent();
while (efile.hasMoreElements()) {
Event event = (Event) efile.nextElement();
m_eventConf.put(event);
}
}
After Change
*/
public static void loadConfiguration(Reader rdr) throws IOException, MarshalException, ValidationException {
synchronized (m_eventConf) {
Events toplevel = CastorUtils.unmarshal(Events.class, rdr);
m_eventConf.clear();
for (Event event : toplevel.getEventCollection()) {
m_eventConf.put(event);
}
m_secureTags = toplevel.getGlobal().getSecurity().getDoNotOverride();
for (String eventFilePath : toplevel.getEventFileCollection()) {
File eventFile = new File(eventFilePath);
InputStream fileIn = new FileInputStream(eventFile);
if (fileIn == null) {
throw new IOException("Eventconf: Failed to load/locate events file: " + eventFile);
}
if (log().isDebugEnabled()) {
log().debug("Eventconf: Loading event file: " + eventFile);
}
Reader filerdr = new InputStreamReader(fileIn);
Events filelevel = CastorUtils.unmarshal(Events.class, filerdr);
if (filelevel.getGlobal() != null) {
throw new ValidationException("The event file " + eventFile + " included from the top-level event configuration file cannot have a 'global' element");
}
if (filelevel.getEventFileCollection().size() > 0) {
throw new ValidationException("The event file " + eventFile + " included from the top-level event configuration file cannot include other configuration files: " + StringUtils.collectionToCommaDelimitedString(filelevel.getEventFileCollection()));
}
for (Event event : filelevel.getEventCollection()) {
m_eventConf.put(event);
}
}